﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using NLog;
using Ubiquity.Web.Filters;

namespace Ubiquity.Web.Controllers
{

    public class HomeController : Controller
    {

        private readonly ILogger<HomeController> _logger;
        static readonly Logger Logger = LogManager.GetCurrentClassLogger();
        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }
        // GET: /<controller>/
        [Authorize]
        public IActionResult Index()
        {  
            Logger.Info("普通信息日志-----------");
            Logger.Debug("调试日志-----------");
            Logger.Error("错误日志-----------");
            Logger.Fatal("异常日志-----------");
            Logger.Warn("警告日志-----------");
            Logger.Trace("跟踪日志-----------");
            Logger.Log(NLog.LogLevel.Warn, "Log日志------------------");

            _logger.LogInformation("你访问了首页");
            _logger.LogWarning("警告信息");
            _logger.LogError("错误信息");
            return View();
        }
    }
}
